url = '/account/orders.html'
description = '用户订单历史'
layout = 'default'

[session]
security = "user"
redirect = "account/login"
==
use Jason\Ccshop\Controllers\Orders;
function onStart() {
    $this['orderStatus'] = (new Orders())->myOrdersStatus();
    $orderStatus = (new Orders())->myOrdersStatus();
    $cr = 0;
    $op = 0;

    foreach($orderStatus as $os){
        if($os['status_id'] == 6){
           $cr += $os['count'];
        }
        if($os['status_id'] == 8){
          $cr += $os['count'];
        }
        if($os['status_id'] == 1){
          $op += $os['count'];
        }
        if($os['status_id'] == 9){
          $op += $os['count'];
        }
    }
  $this['cr']=$cr;
  $this['op']=$op;

  $xxkkcc =App::make('Jason\Ccshop\Components\Catalog')->orders();
 // dd($xxkkcc[0]['products']);



}
==
{% put page_title %}ご注文履歴 - {% default %}{% endput %}
{% set orders = catalog.orders %}
{% set Addresses = catalog.getAddresses %}


<div class="address_content">
		<!-- breadcrumbs -->
		<div class="breadcrumbs">
			<div class="container">
				<ul>
					<li class="fl" ><a href="/">KOKOMI</a></li>
					<li class="fl" >お買物履歴詳細</li>
				</ul>
			</div>
		</div>
		<!-- breadcrumbs end -->

		<div class="orderCont">
			<div class="container">
				<h2 class="pageHead1">お買物履歴詳細</h2>
				<div class="ov dashboardBox">
					<div class="fl d_sidemenus">
						{% partial 'account/left-bar' %}
					</div>
					<div class="fr d_main">
						<div class="main-ttl">お買物履歴詳細</div>
						<div class="detailBox orderBox">
							<div class="detail_date">
								<div class="tab-content" id="orderContent">
									<div class="tab-pane fade in active" id="order-one">
										<div class="table_wrap">
											{% if count(orders) > 0 %}
												<table class="table_type_order">
													<thead>
													<tr>
														<td width="45%">商品情報</td>
														<td>単価</td>
														<td>数量</td>
														<td>注文状况</td>
														<td>合計金額</td>
														<td>備注</td>
													</tr>
													</thead>
													<tbody>

													{% for key, order in orders %}
													{% if order.order_status.code == 'placed' or order.order_status.code == 'pressed' %}
													<tr>
														<th colspan="6"><b>注文NO.：</b>{{ order.sn }}&nbsp;&nbsp;&nbsp;&nbsp;<b>ご注文日付と時間：</b>{{ formatDate("m/d/Y H:i:s", order.created_at) }}</th>
													</tr>
													{% for m, orderproduct in order.products %}
													{% set condition = { 'id': orderproduct.product_id } %}
													{% set product = catalog.product(condition) %}
														<tr>
															<td>												
																<div class="orderdiv">
																	<a class="table_type_a" href="{{product.url}}" title="{{ orderproduct.name }}" target="_blank">
																		<img title="{{ orderproduct.name }}" src="{{ product.getMainThumb(150,150) }}">
																	</a>
																	<p style="clear: both;">
																		<a href="{{product.url}}" target="_blank">{{ orderproduct.name }}</a>
																	</p>			
																</div>												
															</td>
															<td class="subtotal">
																{{ orderproduct.price|formatPriceNotRate }}
															</td>
															<td class="orders_num">
																× {{ orderproduct.qty }}
															</td>
															<td class="total">
																{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}
															</td>
															<td class="subtotal" >
																{{ order.total_price|formatPriceNotRate }}
															</td>
															{% if loop.index ==1%}
															<td class="textAlign" rowspan="{{count(order.products)}}">
																{#{ form_open({'request': 'onRePaymentOrder', 'class': 'checkoutForm','id':'yy_onRePaymentOrder_'~order.sn}) }#}
																<input type="hidden" name="key" value="{{ order.sn }}">
																<a style="padding: 5px 5px; display: block; background: #f56262; border-radius:5px; color: #e8e8e8;" href="/repay-{{ order.sn }}-{{ order.payment_method }}-p.html" class="pay_btn">今すぐ支払う</a>
																<!--<button type="submit" form="yy_onRePaymentOrder_{{order.sn}}">今すぐ支払う</button>-->
																{#{ form_close() }#}
																<!--<p style="margin: 10px 0;"><button><a class="orderXx" href="{{ 'account/orders'|page }}" data-request="onCancelOrder" data-request-data="sn: {{ order.sn }}" >キャンセル</a></button></p>-->
																<p><button><a class="orderXx" href="/orderdetail-{{ order.sn }}.html">詳細</a></button></p>
															</td>
															{% endif %}
														</tr>
													{% endfor %}
													{% endif %}
													{% endfor %}
													</tbody>
												</table>

											{% else %}
											<h4 style="text-align:center;margin-top:20px;color:#615757;">ご注文いただいた履歴はございません。</h4>
											{% endif %}
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="orders_pagination">
							{{ orders.render|raw }}
							<!-- <span class="orders_pagination_btn" style="float: left;">前へ</span>
							<span>
								10 / ページ
							</span>
							<span class="orders_pagination_btn" style="float: right;">次へ</span> -->
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>